<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="专家类型">
              <j-category-select placeholder="请选择专家类型" v-model="queryParam.professorDeclareCategory" pcode="B03"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="专家姓名">
              <a-input placeholder="请输入专家姓名" v-model="queryParam.professorName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="beforeSearchQuery(queryParam.professorDeclareCategory)" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!--              <a @click="handleToggleSearch" style="margin-left: 8px">
                              {{ toggleSearchStatus ? '收起' : '展开' }}
                              <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                            </a>-->
              <a-button @click="handleAdd" type="primary" icon="plus"  style="margin-left: 8px" >编辑专家级别的评分机制</a-button>


              <!--                  <projectProfessorInfo-modal ref="modalForm" @ok="modalFormOk" @Sampling="Sampling"></projectProfessorInfo-modal>-->

            </span>
          </a-col>
        </a-row>
      </a-form>

    </div>
    <div class="table-operator">

    </div>
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a  v-if="selectedRowKeys.length!=0" style="margin-left: 24px" @click="onClearSelected">清空选择</a>
        <a style='margin-left: 50px'>运算机制：总分 = 技术职称分数*20% + 初始分数*30% +（评标次数-拒绝次数-2*紧急请假次数+项目评分平均星数（（近一年数据*2+前一年数据）/3））*100*50%</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="professorName" slot-scope="text,record">
        <a :class="record.isLeave === 0 ? 'fontgreen' :'fontred'" disabled>{{record.professorName}}</a>
        </span>

        <span slot="isLeave" slot-scope="text,record">
        <a :class="record.isLeave === 0 ? 'fontgreen' :'fontred'" disabled>{{record.isLeave === 0?'在职':'请假'}}</a>
        </span>

        <template slot="declareCategory" slot-scope="text">
          <div>{{ initDict(text) }}</div>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit1(record)">更改初始分数</a>
          <a-divider type="vertical" />
          <a @click="handleEdit2(record)">更改专家技术职称</a>

          <!--          <a-dropdown>
                      <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                      <a-menu slot="overlay">
                        <a-menu-item>
                          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                            <a>删除</a>
                          </a-popconfirm>
                        </a-menu-item>

                      </a-menu>
                    </a-dropdown>-->
        </span>

      </a-table>
    </div>




    <info-modal ref="modalForm" @ok="modalFormOk" ></info-modal>

    <info-modal2 ref="OwnForm" @ok="modalFormOk" ></info-modal2>

    <info-modal3 ref="OwnForm2" @ok="modalFormOk" ></info-modal3>



  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { loadCategoryData } from '@/api/api'
import Area from '@/components/_util/Area'
import JCategorySelect from '@comp/jeecg/JCategorySelect'
import infoModal from './modules//infoModal'
import infoModal2 from './modules//infoModal_pro'
import infoModal3 from './modules//infoModal_pro2'

// 导入
import {getAction} from '@/api/manage'

export default {
  name: "DiyProcessPointsSystem",
  mixins:[JeecgListMixin, mixinDevice],
  components: {
    infoModal,
    JCategorySelect,
    getAction,
    infoModal2,
    infoModal3

  },

  data () {
    return {
      propps : [ '正高','副高','中级','初级'],
      description: '专家分数录入管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'专家姓名',
          align:"center", // 居中align
          dataIndex: 'professorName',
        },
        /*   {
             title:'专业',
             align:"center", // 居中align
             dataIndex: 'professorDeclareCategoryName',
           },*/
        {
          title:'技术职称',
          align:"center",
          dataIndex: 'professorTitle',
        },
        {
          title:'技术职称分数',
          align:"center",
          dataIndex: 'technicalTitleScore',
        },
        {
          title:'初始分数',
          align:"center",
          dataIndex: 'firstScore',
        },
        {
          title:'项目分数',
          align:"center",
          dataIndex: 'itemScore',
        },
        {
          title:'总分',
          align:"center",
          dataIndex: 'abcScore'
        },
        {
          title:'评标项目次数',
          align:"center",
          dataIndex: 'evaluationNumber'
        },
        {
          title:'拒绝项目次数',
          align:"center",
          dataIndex: 'rejectItemScore',
        },

        {
          title:'紧急请假次数',
          align:"center",
          dataIndex: 'rejectionScore'
        },
        {
          title:'项目评分平均分数',
          align:"center",
          dataIndex: 'itemRating'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          // fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/org/diyProfessorInfo2/list",
        delete: "/org/diyProfessorInfo2/delete",
        deleteBatch: "/org/diyProfessorInfo2/deleteBatch",
        exportXlsUrl: "/org/diyProfessorInfo2/exportXls",
        importExcelUrl: "org/diyProfessorInfo2/importExcel2",
      },
      dictOptions:{},
      pcaData:''
    }
  },
  created() {
    this.pcaData = new Area()

  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    beforeSearchQuery(type){
      let url = "/sys/category/findById?ids="+type;
      getAction(url).then((res)=>{
        if (res.result == 1){
          alert("请选择正确的专家类型")
        }else {
          this.searchQuery()
        }
      })
    },
    initDict(text){
      let textArray=[]
      textArray= text.split(",")
      let array = []
      array = this.dictOptions.professorDeclareCategory
      let dicts = ''
      // 先判断是否为空
      if(textArray.length!=null && array.length!=null){
        for (let i = 0; i < textArray.length; i++) {
          for (let j = 0; j < array.length; j++) {
            if (textArray[i] == array[j].value){
              dicts += array[j].text
              break
            }
          }
          if(i<textArray.length-1){
            dicts += "，"
          }
        }
      }


      return dicts
    },
    /*      getPcaText(code){

            return this.pcaData.getText(code);
          },*/
    initDictConfig(){

      loadCategoryData({code:'B03'}).then((res) => {
        if (res.success) {
          // 把专家类型的值传入到dictOptions中
          this.$set(this.dictOptions, 'professorDeclareCategory', res.result)
        }
      })
    }
  }
}
</script>
<style scoped>
.fontgreen{
  color:green;
}
.fontyellow{
  color:gold;
}
.fontred{
  color:red;
}
@import '~@assets/less/common.less';
</style>